USE [Restaurant]
GO
/****** Object:  StoredProcedure [dbo].[spSuaChiTietKho]    Script Date: 05/20/2012 12:07:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create Procedure [dbo].[spDeadlock_SuaChiTietKho_Error](@maKho int,@maNL int, @toiDa int, @toiThieu int, @Ton int, @TTrang int)
As
Begin
	begin tran
		set tran isolation level serializable
		if((select count(*) from ChiTietKho 
			Where MaKho = @maKho and MaNL = @maNL) == 1)
		begin
			waitfor delay '00:00:05'
			Update ChiTietKho
				Set
					SucChuaToiDa = @toiDa,
					SucChuaThapNhat = @toiThieu,
					LuongTon = @Ton,
					TinhTrang = @TTrang
				Where MaKho = @maKho and MaNL = @maNL
		end	
	commit
End